package scedu.controller;


import com.scedu.springcloud.entity.Dept;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import scedu.service.DeptService;

import java.util.List;

//提供restful服务
@RestController
@Slf4j
public class DeptController {
    @Autowired
    DeptService service;
    /*添加

     */
    @PostMapping("/add")
    public Integer add(Dept dept){
        return service.addDept(dept);
    }
    /*查询单个

     */
    @GetMapping("/get/{id}")
    public Dept get( @PathVariable("id") Long id){
        log.info("id={}",id);
        return service.queryById(id);
    }
    /*查询所有

     */
    @GetMapping("/all")
    public List<Dept> queryALL(){
        return service.queryALL();
    }


}
